<?php
/**
 * V6
 *
 */
class data_invitation extends data {
	public function __construct() {
		parent::__construct();
	}
	
	protected function make_code ($type, $uid, $circle_id, $addtion_str='') {
		if ($type and $uid and $circle_id) {
			switch ($type) {
				case 'public':
					return 'a'.md5(microtime().$type.$uid.$circle_id.$addtion_str);
					break;
				case 'weibo':
					return 'b'.md5(microtime().$type.$uid.$circle_id.$addtion_str);
					break;
				case 'renren':
					return 'c'.md5(microtime().$type.$uid.$circle_id.$addtion_str);
					break;
				default:
					return false;
			}
		} else return false;
	}
	public function is_code ($code) {
		if (preg_match('/^[0-9|a-f]{33}$/i', $code)) {
			$first_char = substr($code, 0, 1);
			switch ($first_char) {
				case 'a':
					return 'public';
				case 'b':
					return 'weibo';
				case 'c':
					return 'renren';
				default:
					return false;
			}
		} else return false;
	}
}
?>